//
//  HJHttpTool.h
//  project
//
//  Created by hu on 2019/3/20.
//  Copyright © 2019 hu. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"

@class HJResponeds;
typedef void(^SuccessBlock)(HJResponeds *result);
typedef void(^FailureBlock)(id result);

@interface HJHttpTool : NSObject

/*** GET请求 */
+ (void)get:(NSString *)url params:(NSDictionary *)params success:(SuccessBlock)success failure:(FailureBlock)failure;
/*** POST请求 */
+ (void)post:(NSString *)url params:(NSDictionary *)params success:(SuccessBlock)success failure:(FailureBlock)failure;

/*** POST Body */
+ (void)postWithUrl:(NSString *)url body:(NSData *)body success:(SuccessBlock)success failure:(FailureBlock)failure;
/// 上传图片
+ (void)uploadImageWithUrl:(NSString *)url params:(NSDictionary *)params name:(NSString *)name imageArray:(NSArray *)imageArray completion:(void (^)(NSArray *result, NSError *error))completion;

/*** 下载请求*/
+ (void)download:(NSString *)url process:(void (^)(NSInteger writedBytes, NSInteger totalBytes))process success:(void (^)(NSDictionary *result))success failure:(void (^)(NSString *msg))failure;
/*** 上传视频请求*/
+ (void)UploadFile:(NSString *)url filePath:(NSURL *)filePath name:(NSString *)name param:(NSDictionary *)param process:(void (^)(NSInteger writedBytes, NSInteger totalBytes))process success:(void (^)(NSDictionary *result))success failure:(void (^)(NSString *msg))failure;

/*** 将1请求参数转为字符串 */
//+ (NSString *)keyValueStringWithParams:(NSDictionary *)params;


/**
 加入公参
 @param params 设置参数
 @return 所有参数
 */
+ (NSDictionary *)getNewParamsFromParams:(NSDictionary *)params;

/**
 刷新token
 @param success 成功
 */
+(void)refreshTokenWithSuccess:(void(^)(BOOL isYes))success;

+(NSString *)token;
@end




@interface HJResponeds : NSObject

@property (nonatomic,assign) BOOL isSuccess; // 请求是否成功
@property (nonatomic,strong) id data; //请求结果
@property (nonatomic,strong) NSString *resultDesc; //请求结果的描述
@property (nonatomic,assign) NSInteger code;

@end
